home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / getwlst.zip / GETWLST.TXT < prev    next >
Text File  |  1991-07-19  |  6KB  |  132 lines

  1. GetWindowList version 1.1
  2. Lines with a vertical bar (|) are changed from version 1.0
  3.  
  4. Overview 
  5. ------------
  6. GetWindowList is a function, written in C and exported in a dynamic link
  7. library, that creates and returns an array of window handles to active,
  8. | visible (including iconic) windows in your system.  A mode parameter allows
  9. | you to control the types of windows the function returns.
  10.  
  11. What you do with that list of window handles is up to you.  The sample 
  12. VB application, VBSWITCH, is a simple Task Switching program that 
  13. demonstrates the use of the DLL function and several other interesting
  14. Windows techniques, including retrieving the window title from other
  15. active windows, and posting messages to them.
  16.  
  17.  
  18. Usage:    (See sample application for complete implementation)
  19. ------
  20. 'Place this in the Global.BAS code
  21. 'Remember it must live on one line...
  22. Declare Function GetWindowList Lib "Getwlst.dll" (hWndArray As Integer, 
  23. | ByVal nArrayMax As Integer, ByVal nMode as Integer) As Integer
  24.  
  25. | Global Const YOYO = 0     'Yer On Yer Own...
  26. | Global Const ALLVIS = 1
  27. | Global Const TOPONLY = 2
  28. | Global Const SAFEST = 3
  29.  
  30.  
  31. 'Place these in a declarations section
  32. Dim hWndArray(nRequested%) as Integer
  33. Dim nWndCnt as Integer
  34.  
  35. ' The function call...
  36. nUBound = UBound(hWndArray)
  37. nWndCnt = GetWindowList( hWndArray, nUBound)
  38.  
  39. Parameters:
  40. -----------
  41. hWndArray: An array of integers.  Your window handle list is returned
  42. in this array.
  43.  
  44. nUBound:  This can be any number less than or equal to the 
  45. number of elements in the array.  This tells the function when to stop
  46. filling the array with window handles and prevents wanton corruption of
  47. memory.
  48.  
  49. | nMode: Is the mode specifying the volume of windows you want returned.
  50.  
  51. | Mode explanation
  52. | ----------------
  53. | YOYO(0)    : Returns ALL (repeat, ALL) windows, including invisible, system, desktop
  54. |              and the task which called the function (i.e. your VB app).
  55. |              This mode is AKA How to Trash Windows Without Really Trying.  You have
  56. |              been warned.
  57. |              Please note:  You will probably see lots if "windows" in the list box
  58. |              with a blank caption.  I don't know what they are, nor where they come from.
  59. |              It might provide an interesting starting leap for futher investigation, though
  60. |              the leap may be straight off the edge and down.  Again, you're straddling the
  61. |              bleeding edge of calamity with this mode.
  62. | ALLVIS(1)  : Returns all visible windows.  It will return all popup windows for every running,
  63. |              visible task. This includes modal and modeless dialog boxes, and any
  64. |              active message boxes.
  65. | TOPONLY(2) : Returns visible TOP LEVEL windows only. (i.e. GetParent(hWnd) == NULL )
  66. | SAFEST(3)  : In SDK programming, calls to the MessageBox function take a window handle
  67. |              parameter, which call be NULL, effectively making the message box a top level
  68. |              window.  This parameter filters out these "top level" message boxes.
  69.  
  70.  
  71. Return Value:  
  72. -------------
  73. An integer, the actual number of window handles found.  Use
  74. this value, not nUBound, to traverse the list of window handles.
  75.  
  76. Notes:
  77. ------
  78. 1.  Your hWndArray subscript must be less than 40.  The DLL uses an internal
  79. static array to store the window handles before placing them in the VB array
  80. passed as a parameter.  If you try to pass a number greater than 40, the DLL
  81. will simply bump you back to 40.
  82.  
  83. 2.  Do _not_ pass an nUBound parameter larger than the upper bound of the 
  84. hWndArray.  Doing so will crash your system if the actual number of active 
  85. windows is greater than the number of elements in the array.
  86.  
  87. 3.  This function will not return the window handles of the following: The 
  88. current task, the desktop, any hidden windows.
  89.  
  90. | 4.  If you insist on using YOYO mode (note that I _could_ have said 'If you 
  91. | insist on being a YOYO,' but I didn't), make sure you set the UBound of your 
  92. | window handle array quite high as you'll get back a lot more windows than
  93. | you might expect.
  94.  
  95.  
  96. Disclaimer
  97. ----------
  98. The DLL itself is copyright by Todd Steinwart of Morris & Steinwart.  
  99. It is provided free of charge for your use, and you may 
  100. redistribute it without further consideration to Morris & Steinwart.
  101. The source for the DLL is not available.
  102.  
  103. Morris & Steinwart makes no warranties, either express or implied, as to the
  104. fitness of this DLL and the functionality contained within.  You use this 
  105. package at your own risk.
  106.  
  107. The source for VBSWITCH is hereby entered into the public domain.
  108.  
  109. Credit
  110. ------
  111. I owe a debt of gratitude to Jeffrey Richter and his book _Windows 3:
  112. A Developer's Guide_ (of course I paid B. Dalton Books almost 40 bucks
  113. for the book+disks, so overall I think we're even) for making several
  114. aspects of this little DLL quite trivial.  His supplied "Voyeur" 
  115. application made it quite easy to watch Windows from behind the scenes.
  116. I highly recommend this book for those who have graduated from "Petzold."
  117. It is written with the SDK programmer in mind, but many of the techniques
  118. can be used in VB.
  119.  
  120. About Morris & Steinwart
  121. ------------------------
  122. Gregg Morris (CIS 72447,1545) and Todd Steinwart (CIS 73647,1613) do consulting
  123. and contract work in the Windows arena, and specialize in C (SDK), SqlWindows,
  124. Visual Basic and Superbase programming.  If you need extra hands for Windows
  125. development, drop us a line and we may be able to help.
  126.  
  127.  
  128.  
  129. Distributed by Public (software) Library.
  130. For a catalog of more than 3000 disks of pd/shareware, call 1-800-2424-PSL
  131. or write Public (software) Library, P.O.Box 35705, Houston, TX 77235-5705.
  132.